//
//  FHYLoginViewController.m
//  Education
//
//  Created by 姬鑫宇 on 14-9-10.
//  Copyright (c) 2014年 姬鑫宇. All rights reserved.
//

#import "FHYLoginViewController.h"

@interface FHYLoginViewController ()

@end

@implementation FHYLoginViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBarHidden = YES;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(IBAction)loginBtnPress:(id)sender{
    [FHYModel loginWithBlock:^(BOOL result, FHYLogInModel *userDic, NSString *failedMessage, NSError *error) {
        if (result) {
            //存储用户名和密码到本地
            NSUserDefaults *userDefault =[NSUserDefaults standardUserDefaults];
            [userDefault setObject:[NSString stringWithFormat:@"%@", _nameText.text] forKey:@"userName"];
            [userDefault setObject:[NSString stringWithFormat:@"%@", _codeText.text] forKey:@"userCode"];
            [userDefault synchronize];
            
            [self.navigationController popViewControllerAnimated:YES];
        }
    } withUserName:_nameText.text password:_codeText.text];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
